import request from "@/utils/request";
import type { RuleForm } from '@/views/user/student-edit.vue'

export type LoginParamsType = {
    userName: string
    password: string
    rember?: boolean
}
export type UserPageListParamsType = {
    userName: string,
    role: 1 | 2 | 3,
    pageIndex: number,
    pageSize: number
}
export type UserPageListResListType = {
    id: any,
    userName: string,
    realName: string,
    age: number,
    role: 1 | 2 | 3,
    sex: 1 | 2,
    birthDay: string,
    phone: string,
    createTime: string,
    status: number,
    userLevel: number
}
export type UserPageListResType = {
    total: number,
    list: UserPageListResListType[],
    pageNum: number,
    pageSize: number
}

export function login(data: LoginParamsType) {
    return request.post('/api/user/login', data)
}

export function logout() {
    return request.post('/api/user/logout')
}

export function userPageList(data: UserPageListParamsType) {
    return request.post<UserPageListResType>('/api/admin/user/page/list', data)
}

export function userSelect(id: any) {
    return request.post<UserPageListResListType>('/api/admin/user/select/' + id)
}

export function userEdit(data: RuleForm) {
    return request.post('/api/admin/user/edit', data)
}

export function userDelete(id: number) {
    return request.post('/api/admin/user/delete/' + id)
}

export function userStatus(id: number) {
    return request.post('/api/admin/user/changeStatus/' + id)
}